<template>
  <view class="ag_container">
    <view class="agree_jn">
      <!-- 步骤条 -->
      <uni-steps :options="steps" :active="1" active-color="#00a660"></uni-steps>
      <view class="authentication_payCon">
        <view class="code-text">
          <p>尊敬的法定代表人：</p>
          <view><span class="themeColor">{{ companyName }}</span>
            认证信息已完善，请您（法定代表人）进行人脸核身验证，验证通过后，系统将自动通过国家工商系统核验法定代表人身份信息，全部核验通过后，企业完成实名认证！
          </view>
        </view>
      </view>
      <!-- 提交审核 -->
      <view class="select_pay">
        <view class="footer-Btn">
          <button @click="revokeCert" class="back-Btn">撤销认证</button>
          <button @click="submitForm" class="next-Btn">人脸识别验证</button>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import {revokeLegalCert} from "@/api/ec/work/company/companyCertification";
import {EncryptCommon} from "../../../api/login";

export default {
  data() {
    return {
      // 认证步骤
      steps: [{title: '完善单位信息'}, {title: '核验单位信息'}, {title: '实名认证通过'}],
      // 企业id
      companyId: '',
      // 企业名称
      companyName: '',
    };
  },
  onLoad(option) {
    this.companyId = option.id;
    this.companyName = option.companyName;
  },
  created() {
  },
  methods: {
    /** 撤销认证 */
    revokeCert() {
      this.$modal.loading();
      revokeLegalCert(this.companyId).then((response) => {
        uni.hideLoading()
        this.$modal.msgSuccess("撤销认证");
        setTimeout(() => {
          uni.redirectTo({url: '/pages/authentication/companyRealname/start?id=' + this.companyId});
        }, 1000);
      }).catch(() => {
        uni.hideLoading()
      });
    },
    /** 跳转到人脸认证 */
    async submitForm() {
      let param = {};
      param.mobile = this.$store.getters.staffInfo.mobile;
      param.name = this.$store.getters.staffInfo.name;
      param.idNumber = this.$store.getters.staffInfo.idNumber;
      param.staffId = this.$store.getters.staffInfo.id;
      param.companyId = this.companyId;
      param.dirName = "legalFace";
      let data;
      // 加密参数
      await EncryptCommon(new Buffer(JSON.stringify(param)).toString('base64')).then((response) => {
        data = response;
      });
      uni.navigateTo({url: '/pages/authentication/personal/facePersonal?source=mobile&verifyType=2&data=' + data});
    },
  },
};
</script>
<style lang="scss" scoped>
.code-text {
  margin-top: 18rpx;

  p {
    font-size: 28rpx !important;
    color: #555;
  }

  view {
    margin-top: 12rpx;
    text-indent: 2rem;
    font-size: 26rpx;
    color: #777;
    line-height: 36rpx;
  }
}

page {
  background-color: $uni-bg-color;
}

.ag_container {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.agree_jn {
  margin-top: 40rpx;
  padding: 0 30rpx;
  position: relative;
}

.authentication_payCon {
  color: #999999;
  padding: 20rpx;

  p {
    margin: 0;
    font-size: 24rpx;
    padding: 1rpx 0;
  }
}

.select_pay {
  color: #999999;
  margin: 40rpx 0;

  .footer-Btn {
    margin: 20rpx 0 40rpx 0;
    display: flex;
    justify-content: space-between;

    button {
      width: 48%;
      font-size: 28rpx;
    }

    .next-Btn {
      background-color: $uni-color-primary;
      border-radius: 10rpx;
      color: #fff;
    }

    .back-Btn {
      border-radius: 10rpx;
      border: solid 1rpx $uni-color-primary;
      color: $uni-color-primary;
      background: #fff;
    }
  }
}

</style>
